package com.vishnu.action;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.LookupDispatchAction;
import org.apache.struts.validator.DynaValidatorForm;

public class BMSAction extends LookupDispatchAction  {

	public Map<String,String> getKeyMethodMap(){
		Map<String,String> map=new HashMap<String,String>();
		map.put("button.save", "save");
		map.put("button.delete", "delete");
		map.put("button.update", "update");
		map.put("button.search", "search");
		return map;		
	}
	
	public ActionForward save(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception{
		
		System.out.println("------------entered into SAVE BmsAction.....----------");
		ActionForward af=null;
		af=mapping.findForward("saved");
		
		DynaValidatorForm dvf	=(DynaValidatorForm)form;
		
		System.out.println("------Action class--------");
		
		System.out.println("Pid="+dvf.get("pid"));
		System.out.println("Pname="+dvf.get("pname"));
		System.out.println("Pprice="+dvf.get("pprice"));

		return af;
	}
	
	public ActionForward delete(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception{
		
		System.out.println("------------entered into DELETE BmsAction.....----------");
		ActionForward af=null;
		af=mapping.findForward("deleted");
		
		DynaValidatorForm dvf	=(DynaValidatorForm)form;
		
		System.out.println("------Action class--------");
		
		System.out.println("Pid="+dvf.get("pid"));


		return af;
	}

	public ActionForward update(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception{
		
		System.out.println("------------entered into UPDATE BmsAction.....----------");
		ActionForward af=null;
		af=mapping.findForward("updated");
		
		DynaValidatorForm dvf	=(DynaValidatorForm)form;
		
		System.out.println("------Action class--------");
		
		System.out.println("Pid="+dvf.get("pid"));
		System.out.println("Pname="+dvf.get("pname"));
		System.out.println("Pprice="+dvf.get("pprice"));

		return af;
	}
	
	public ActionForward search(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception{
		
		System.out.println("------------entered into SEARCH BmsAction.....----------");
		ActionForward af=null;
		af=mapping.findForward("search");
		
		DynaValidatorForm dvf	=(DynaValidatorForm)form;
		
		System.out.println("------Action class--------");
		
		System.out.println("Pid="+dvf.get("pid"));


		return af;
	}
}
